package com.hm.homepage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hm.homepage.entity.Website;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface WebsiteMapper extends BaseMapper<Website> {
    @Select("SELECT DISTINCT category FROM websites WHERE category IS NOT NULL AND category != ''")
    List<String> selectAllCategories();
    
    @Select("SELECT * FROM websites WHERE category = #{category} ORDER BY created_at DESC")
    List<Website> selectByCategoryOrderByCreatedAtDesc(String category);
}